package com.hinnotek.amoeba.adapters.old

import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.hinnotek.amoeba.R
import com.hinnotek.amoeba.bean.old.SellPurchaseRequistionBean

class SellPurchaseRequisitionAdapter :
    BaseQuickAdapter<SellPurchaseRequistionBean, BaseViewHolder>(R.layout.item_sell_purchase_requisition) {
    private var purchase_type_to: String? = null
    fun setPurchase_type_to(purchase_type_to: String?) {
        this.purchase_type_to = purchase_type_to
    }

    override fun convert(holder: BaseViewHolder, item: SellPurchaseRequistionBean) {
        if (purchase_type_to == "market" || purchase_type_to == "technology") {
            holder.setText(R.id.tv_sell_user_name, item.customerName)
            holder.setText(R.id.tv_sell_related_project, item.projectName)
        } else if (purchase_type_to == "rD") {
            holder.setVisible(R.id.ll_sell_user_name, false)
            holder.setText(R.id.tv_sell_related_project, item.provideProjectName)
        }
        holder.setText(R.id.tv_sell_type, if (item.applicationMethod == 1) "首次" else "变更")
        when (item.approvalState) {
            1 -> {
                holder.setText(R.id.tv_status, "已申请")
                holder.setTextColor(R.id.tv_status, ContextCompat.getColor(context,R.color.black))
            }
            2 -> {
                holder.setText(R.id.tv_status, "已同意")
                holder.setTextColor(
                    R.id.tv_status,
                    ContextCompat.getColor(context,R.color.xui_btn_green_normal_color)
                )
            }
            3 -> {
                holder.setText(R.id.tv_status, "已拒绝")
                holder.setTextColor(
                    R.id.tv_status,
                    ContextCompat.getColor(context,R.color.xui_config_color_red)
                )
            }
            4 -> {
                holder.setText(R.id.tv_status, "已撤回")
                holder.setTextColor(
                    R.id.tv_status,
                    ContextCompat.getColor(context,R.color.xui_config_color_red)
                )
            }
        }
    }
}